package com.manage.server.controller.admin;

import com.manage.dto.UserActivityDTO;
import com.manage.dto.add.UserActivityAddDTO;
import com.manage.dto.update.UserActivityUpdateDTO;
import com.manage.result.PageResult;
import com.manage.server.service.UserActivityService;
import com.manage.vo.UserActivityVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.manage.result.Result;

@RestController
@RequestMapping("/userActivity")
public class UserActivityController {

    @Autowired
    private UserActivityService userActivityService;

    @PostMapping
    public Result add(@RequestBody UserActivityAddDTO userActivityAddDTO) {
        userActivityService.save(userActivityAddDTO);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        userActivityService.removeById(id);
        return Result.success();
    }

    @PutMapping
    public Result update(@RequestBody UserActivityUpdateDTO userActivityUpdateDTO) {
        userActivityService.updateById(userActivityUpdateDTO);
        return Result.success();
    }

    /**
     * 多项分类分页查询
     * @param userActivityDTO
     * @return
     */
    @PostMapping("/page")
    public PageResult<UserActivityVO> findUserActivity(@RequestBody UserActivityDTO userActivityDTO) {
        return userActivityService.findUserActivityByPage(userActivityDTO);
    }
}